﻿using System;
using System.Collections.Generic;

using System.Text;

namespace NLBS.Control
{
   public class Utils
    {
    
       public static bool ParseBool(object o, bool defaultValue)
       {
           if ((o == null) || (o.ToString() == ""))
           {
               return defaultValue;
           }
           string text = o.ToString().ToLower();
           switch (text)
           {
               case "true":
               case "1":
                   return true;
           }
           if ((text != "false") && (text != "0"))
           {
               throw new FormatException("'" + o.ToString() + "' can not be parsed as a bool.");
           }
           return false;
       }
    }
}
